﻿package com.wabbei.friendcenter.action;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import com.webbei.friendcenter.service.MyFriendCenter;
import org.apache.struts2.ServletActionContext;
public class AddFriendsAction {
	private MyFriendCenter friservice;
	private String addUser;//��Ҫ���ӵ���
	private String ownUser;//����
	private InputStream inputstream;
	
	
	public InputStream getInputstream() {
		String result="true";

		ownUser=(String)ServletActionContext.getContext().getSession().get("username");
		System.out.println("add friend.....");
		int i=friservice.addNewFriendByOwnUser(ownUser,addUser);
		int j=friservice.addNewFriendByOwnUser(addUser,ownUser);
		if(i+j==2){
			result="true";
		}else{
			result="false";
		}
		inputstream=new ByteArrayInputStream(result.getBytes());
		return inputstream;
	}

	public void setInputstream(InputStream inputstream) {
		this.inputstream = inputstream;
	}

	public String getOwnUser() {
		return ownUser;
	}

	public void setOwnUser(String ownUser) {
		this.ownUser = ownUser;
	}

	public String getAddUser() {
		return addUser;
	}

	public void setAddUser(String addUser) {
		this.addUser = addUser;
	}

	public MyFriendCenter getFriservice() {
		return friservice;
	}

	public void setFriservice(MyFriendCenter friservice) {
		this.friservice = friservice;
	}
	
	public String execute(){
		return "success";
	}
}
